package cz.byteworks.sandbox.html5.newsbox.jms;

import javax.jms.JMSException;
import javax.jms.ObjectMessage;

import org.apache.activemq.command.ActiveMQObjectMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;

import cz.byteworks.sandbox.html5.newsbox.model.NewsMessage;

@Component
public class JmsMessageSender {
    
    @Autowired
    private JmsTemplate jmsTemplate;
 
    public void send(final NewsMessage message) throws JMSException {
        ObjectMessage objectMessage = new ActiveMQObjectMessage();
        objectMessage.setObject(message);
        jmsTemplate.convertAndSend(objectMessage);
    }

}
